package lena;

import lib.Actor;
import lib.ActorAddress;
import lib.Message;
import java.util.Scanner;
 
public class UserEntryActor extends Actor{

	public UserEntryActor(ActorAddress superActor,ActorAddress myAddress) throws Exception{
		super(superActor,myAddress,"UserEntryActor");
		startActor();
	}

	protected boolean standardRoutine() throws Exception{
		System.out.println("Filename:");
		Scanner sc = new Scanner(System.in);
		String filename=sc.nextLine();
		System.out.println("Select operation: 1-Mirror, 2-Binarize, 3-Black and White, 4-Mix");
		int operationInt;
		try{
			operationInt=(new Integer(sc.nextLine())).intValue();
		}
		catch (NumberFormatException e){
			System.out.println("You haven't typed a number");
			return true;
		}
		String operation=null;
		switch(operationInt){
			case 1:
				operation="Mirror";
				break;
			case 2:
				operation="Binarize";
				break;
			case 3:
				operation="NoirBlanc";
				break;
			case 4:
				operation="Mix";
				break;
			default:
				System.out.println("Invalid operation");
				return true;
		}
		sendMsg(new Message(myAddress, "UserEntryActor", "OpenerActor", operation, filename));
		System.out.println("Message sent\n");
		
		return true;
	}

	protected boolean handleMessage(Message msg) throws Exception{
		if (msg.getOperation().equals("Terminate")) {
			return false;
		}
		
		return true;
	}
}

